<template>
  <div class="MyTeam">
    <div class="msg">队员</div>
    <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
      <van-list
        v-model="loading"
        :finished="finished"
        loading-text="加载中..."
        finished-text="没有更多数据了~"
        @load="onLoad"
        style="background: #ffffff"
        :offset="10"
        :immediate-check="false"
      >
        <UserList :data="list" />
      </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
import UserList from "@/components/UserList";
export default {
  data() {
    return {
      list: [],
      pageNumber: 1,
      pageSize: 10,
      loading: false,
      finished: true,
      isLoading: false,
    };
  },
  components: { UserList },
  methods: {},
  created() {
    this.getTeamList();
  },
  methods: {
    //刷新
    onRefresh() {
      this.isLoading = true;
      this.list = [];
      this.pageNumber = 1;
      this.getTeamList();
    },
    //分页
    onLoad() {
      this.loading = true;
      this.pageNumber += 1;
      this.getTeamList();
    },
    //获取团队列表
    getTeamList() {
      let _self = this;
      this.$toast.loading({
        duration: 0, // 持续展示 toast
        forbidClick: true,
        message: "加载中",
      });
      this.$Api
        .getTeamList({
          pageNumber: this.pageNumber,
          pageSize: this.pageSize,
          accountId: this.$store.state.userInfo
            ? this.$store.state.userInfo.id
            : "",
          series: 1,
          parentId: "",
        })
        .then((res) => {
          if (res.code == 1) {
            _self.$toast.clear();
            _self.list = _self.list.concat(res.data.list);
            _self.finished = res.data.lastPage;
            _self.loading = false;
            _self.isLoading = false;
          }
        });
    },
  },
};
</script>

<style scoped>
.MyTeam {
  background: #f8f8f8;
}
.MyTeam .msg {
  background: #f8f8f8;
  height: 83px;
  padding-left: 27px;
}
</style>